package com.test.pudamoney.activity_fragment_pudamoney.base_pudamoney;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.test.pudamoney.bean_pudamoney.user_info_pudamoney.LoginInfo_pudamoney;
import com.test.pudamoney.util_pudamoney.helper_pudamoney.UserInfoHelper_pudamoney;
import com.test.pudamoney.util_pudamoney.http_pudamoney.HttpManager_pudamoney;
import com.test.pudamoney.util_pudamoney.analytics_pudamoney.event_pudamoney.IAnalyticsEvent_pudamoney;
import com.test.pudamoney.util_pudamoney.analytics_pudamoney.util_pudamoney.AnalyticsUtil_pudamoney;

import org.json.JSONObject;


public abstract class BaseLoginActivity_pudamoney extends BaseActivity_pudamoney {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public abstract void onRequestOtpCodeResponse_pudamoney(String msg,JSONObject jsonObject);

    //登录成功响应
    public void onUserLoginResponse_pudamoney() {
        try {
            //String phoneNum = UserInfoHelper.getInstance().getMobile();
            //打点
            String gtype = LoginInfo_pudamoney.getInstance().getType();
            if (gtype.equalsIgnoreCase(UserInfoHelper_pudamoney.LOGIN_TYPE_REGISTER)) {
//                AFInstallHelper.getInstance().saveEventInfo(AFInstallHelper.AFEvent.AT_REGISTER);
//                FirebaseHelper.getInstance().saveEventInfo(AFInstallHelper.AFEvent.AT_REGISTER);
                AnalyticsUtil_pudamoney.INSTANCE.addEvent(IAnalyticsEvent_pudamoney.AT_REGISTER);
            }

            //保存登录信息到本地
            UserInfoHelper_pudamoney.getInstance().setToken(LoginInfo_pudamoney.getInstance().getToken());
            UserInfoHelper_pudamoney.getInstance().setUserId(LoginInfo_pudamoney.getInstance().getUserId());
            //UserInfoHelper.getInstance().setMobile(phoneNum);

            login();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void login(){
        //登录前初始化
        AnalyticsUtil_pudamoney.INSTANCE.initDevice(BaseApplication_pudamoney.getApplication_pudamoney());
        AnalyticsUtil_pudamoney.INSTANCE.saveFirebaseAndFacebookS2SInfo();
        //请求用户流程信息
        HttpManager_pudamoney.getInstance().requestUserProcess();
    }

}